package com.fieldchain.ex.fa100.custom.view;

import android.animation.Animator;
import android.animation.ValueAnimator;

import com.fieldchain.ex.fa100.inter.AnimationCallBack;
import com.fieldchain.ex.fa100.inter.IntegerCallBack;

/**
 * Created by biyunlong
 * Email: 1225198434@qq.com
 * Data:  2018/9/10
 */
public class MyAnimationUtils {
    public static void setListener(ValueAnimator animator, final IntegerCallBack listener){
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                listener.index((Integer) valueAnimator.getAnimatedValue());
            }
        });
    }
    public static void setListener(ValueAnimator animator, final AnimationCallBack listener){
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                listener.index((Integer) valueAnimator.getAnimatedValue());
            }
        });
        animator.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animator) {

            }

            @Override
            public void onAnimationEnd(Animator animator) {
              listener.onEnd();
            }

            @Override
            public void onAnimationCancel(Animator animator) {

            }

            @Override
            public void onAnimationRepeat(Animator animator) {

            }
        });
    }
}
